package com.foreknow.elm.controller;

import com.foreknow.elm.po.User;
import com.foreknow.elm.service.impl.UserServiceImpl;
import javax.servlet.http.HttpServletRequest;

public class UserController {
    // 获取前台请求参数 /UserController/getUserByIdByPass?userId=?&password=?
    public Object getUserByIdByPass(HttpServletRequest request){
        UserServiceImpl userService = new UserServiceImpl();
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        User user = userService.getUserByIdByPass(userId,password);
        return user;
    }
    // 获取前台请求参数 /UserController/getUserById?userId=?
    public Object getUserById(HttpServletRequest request){
        UserServiceImpl userService = new UserServiceImpl();
        int i = userService.getUserById(request.getParameter("userId"));
        return i;
    }

    public Object saveUser(HttpServletRequest request){
        //获取前台请求参数 /UserController/saveUser?userId=?&password=?&userName=?&userSex=?
        UserServiceImpl userService = new UserServiceImpl();
        int i = userService.saveUser(request.getParameter("userId"),request.getParameter("password"),request.getParameter("userName"),Integer.parseInt(request.getParameter("userSex")));
        return i;
    }
}
